import java.io.IOException;

import com.google.code.javascribd.connection.ScribdClient;
import com.google.code.javascribd.connection.ScribdConnectionException;
import com.google.code.javascribd.docs.Search;
import com.google.code.javascribd.docs.SearchResponse;
import com.google.code.javascribd.type.ApiKey;
import com.google.code.javascribd.type.SearchScope;

public class SearchSnippet {
	public static void main(String[] args) throws ScribdConnectionException, IOException {

		// new instance of ScribdClient
		ScribdClient client = new ScribdClient();

		// initialize required method parameters
		ApiKey apiKey = new ApiKey("scripd_api_key");
		String query = "java";

		// initialize search method
		Search search = new Search(apiKey, query);
		search.setScope(SearchScope.ALL);

		// execute
		SearchResponse response = client.execute(search);

		// get response values e.g. print out the results
		for (SearchResponse.Entry result : response.getResultSet().getEntries()) {
			System.out.printf("%d - %s\n", result.getDocId().intValue(), result.getTitle());
		}

		// output:
		//		
		// 7407127 - Refcardz #24: Core Java
		// 1186576 - Java Software Solution Cap1
		// 7065744 - Fourier Transform: a Java Advanced Imaging implementation
		// 1787476 - Java 2 Exam Cram~Bill Brogden Book
		// 1787597 - Java Language Specification~Sun com~300p
		// 2075607 - Java Tools and JDK-A Primer
		// 2023631 - Sockets en Java
		// 2066065 - Passo a passo java DB2 WID
		// 4230954 - A Comparative Analysis of Object-relational mappings for Java
		// 4395087 - java basico
	}
}
